package com.codeZ.CompositePattern.example;

import java.util.ArrayList;
import java.util.List;

/**
 * 树枝节点
 *
 * @author codeZhang
 * @Date 2024/8/15 10:46
 */
public class Composite extends Component {

    private final List<Component> componentList = new ArrayList<>();

    @Override
    public void add(Component component) {
        componentList.add(component);
    }

    @Override
    public void remove(Component component) {
        componentList.remove(component);
    }

    @Override
    public Component getChild(int index) {
        return componentList.get(index);
    }
}
